function noecho() {
        str="$1"
        if [ `echo "\\c" | wc -l` -eq 0 ]; then
                fo="";bo="\c"
        else
                fo="-n";bo=""
        fi

        echo $fo "$str" $bo
}

function xverify() {
        qstr=$1  # query string
        yes=$2  # affirmative choice
        no=$3   # negative choice
        def=$4  # default choice

        while true; do \
                # issue query
                noecho "$qstr? ($yes/$no): "
                read ans < /dev/tty
                if [ -z "$ans" ]; then
                        ans=$def
                fi

                # translate all to lowercase.
                tyes=`echo $yes | tr [:upper:] [:lower:]`
                tno=`echo $no |  tr [:upper:] [:lower:]`
                ans=`echo $ans |  tr [:upper:] [:lower:]`

                if [ "$ans" = "$tyes" ]; then
                        return 0
                elif [ "$ans" = "$tno" ]; then
                        return 1
                else
                        echo ""
                        echo "Please enter '$yes' for Yes or '$no' for No."
                        echo "Lower or Upper case letters may be used."
                        echo "The capital letter is the default."
                fi
        done
}

function usage() {
        echo "install.sh [prod]"
        echo "Defaults to pre production if any arg other than prod is used."
        exit 0
}

export PLATFORM=""
case $1 in
        -help|--help|-h|--h) usage
        ;;

        'prod') xverify "Production mode install, continue" y N N || exit 0
                echo "Entering production installation."
		PLATFORM=prod
        ;;
        *) echo "Pre-Prodution mode install."
		PLATFORM=preprod
        ;;
esac
